package com.qf.controller;

import com.qf.pojo.User;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 搜索服务
 * @author 千锋健哥
 */
@RestController
@RequestMapping("/search")
public class SearchController {

    /**
     * 模拟被调用的接口
     * @return
     */
    @GetMapping("/test")
    public String test() {
        //模拟异常
        //int i = 1/0;
        return "search微服务被访问到了!";
    }

    @GetMapping("/findByName/{name}")
    public List<User> findByName(@PathVariable(value = "name") String name) {
        List<User> userList = new ArrayList<>();
        User user = new User();
        user.setName("张三");
        user.setId(1);
        userList.add(user);
        return userList;
    }

    @PutMapping("/update")
    public void updateUser(@RequestBody User user) {
        System.out.println("修改成功!");
    }
}
